function err_ = quickTA_err(q)% function err_ = quickTA_err(q)%% Computes the error of the temporal-accumulation (TA) Quick%   fit, given the data (as a global) and the Quick parameters%   (q). Used by fmincon.%% Input:%   q is the 3 quick parameters:%     q(1) = r (response of single channel)%     q(2) = beta (shape/slope term)%     q(3) = lambda (upper asymptote)% % Returns:%     err_ ... the negative of the log likelihood of obtaining%             the data under the parameters qglobal DATA% compute the p'sps = quickTA_val(DATA(:,1), DATA(:,2), q(1), q(2), q(3));% compute log Likelihood of (data | z)% note that fmincon searches for minimum, which% is why we send the negatve of logL% Now calculate the joint probability of obtaining the data set conceived as% a list of Bernoulli trials.  This is just ps for trials = 1 and 1-ps for% trials of 0.p    = [ps(DATA(:,3)==1); 1-ps(DATA(:,3)==0)];err_ = -sum(log(p));			% minus log likelihood